package org.jeecg.common.util;

import cn.hutool.core.bean.copier.CopyOptions;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author gbstart
 * @create 2024-06-07 15:17
 */
public class BeanPlusUtil extends cn.hutool.core.bean.BeanUtil {

        public static <T, E> List<T> toBeanList(Collection<E> sourceList, Class<T> destinationClass) {
            return sourceList != null && !sourceList.isEmpty() && destinationClass != null ? (List)sourceList.parallelStream().filter((item) -> {
                return item != null;
            }).map((source) -> {
                return toBean(source, destinationClass);
            }).collect(Collectors.toList()) : Collections.emptyList();
        }

        public static <T, E> List<T> toBeanList(Collection<E> sourceList, Class<T> destinationClass,String... ignoreProperties) {
            return sourceList != null && !sourceList.isEmpty() && destinationClass != null ? (List)sourceList.parallelStream().filter((item) -> {
                return item != null;
            }).map((source) -> {
                return toBean(source, destinationClass, CopyOptions.create().setIgnoreProperties(ignoreProperties));
            }).collect(Collectors.toList()) : Collections.emptyList();
        }

}
